package xiegd.com.springbootuse.demo.beanDemo;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @Author: xieguangda
 * @Description:
 * @Date: 2023/9/14 17:24
 */
public class MyBeanPostProcessor implements BeanPostProcessor {


    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        // 在 bean 初始化之前进行一些预处理操作
        // ...
        System.out.println("我是初始化前的 " + beanName);
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        // 在 bean 初始化之后进行一些后处理操作
        // ...
        System.out.println("我是初始化之后的"+ beanName);
        return bean;
    }
}
